function editOrder(button){
	var address = button.id;
	$("#datePicker_"+address).datepicker({
		onSelect:function(dateString,datePicker){
			if(!isEarlierThanToday(dateString)){
				var timeString = convertTimeString(dateString);
				changeOrder(timeString,address);
				$("#datePicker_"+address).hide();
			}else{
				alert("Please select a date later than today.")
			}
		}
	});
}

function changeOrder(timeString,orderNum){

	$.post("http://localhost/cs2102/src/editOrder.php",
	{
		orderNum:orderNum,
		time:timeString
	},
	function(dataJson,status){
		alert("wrong");
	});

	window.location.href = "user.html";
}

function convertTimeString(dateString){
	var month = dateString.substring(0,2);
	var date = dateString.substring(3,5);
	var year = dateString.substring(6,10);

	var result = year+"-"+month+"-"+date;
	return result;
}